function RecoilEnergyFromResidueTheta(filename)
  % Linear least squares polyfit to get E_{recoil}(theta_{residue}).
  % Expects Nx4 matrix, where the columns contain recoil angle, energy,
  % residue and and energy, respectively.
	a = load(filename);
	len = size(a, 1);
	theta_residue = a(:, 3);
	energy_recoil = a(:, 2);
  coeff = [theta_residue.^0 theta_residue.^1 theta_residue.^2 ...
      theta_residue.^3 theta_residue.^4 theta_residue.^5 theta_residue.^6] ...
      \ energy_recoil
	t = linspace(0, pi);
  plot(theta_residue, energy_recoil, '.', t, coeff(7)*t.^6 + coeff(6)*t.^5 ...
      + coeff(5)*t.^4 + coeff(4)*t.^3 + coeff(3)*t.^2 + coeff(2)*t.^1 + ...
      coeff(1));
endfunction
